﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

public partial class mobile_product : System.Web.UI.Page
{
    public string pid;
    protected void Page_Load(object sender, EventArgs e)
    {
        pid = Request.Params["pid"].ToString();
        SqlConnection sc = new SqlConnection(ConfigurationManager.ConnectionStrings["wbkpt"].ConnectionString.ToString());
        sc.Open();
        if (pid[0] == 'P')
        {
            SqlCommand get_pname = new SqlCommand("select PRODUCT_NAME from INFO_PRODUCT where PRODUCT_ID=@id", sc);
            get_pname.Parameters.AddWithValue("@id", pid);
            label1.Text = get_pname.ExecuteScalar().ToString();
            SqlCommand get_pintro = new SqlCommand("select PRODUCT_INTRO from INFO_PRODUCT where PRODUCT_ID=@idd", sc);
            get_pintro.Parameters.AddWithValue("@idd", pid);
            string tex=get_pintro.ExecuteScalar().ToString();

            tex=tex.Replace(" ","&nbsp");
            tex = tex.Replace("\n", "<br />");
            textbox1.Text = tex;
            SqlCommand get_purl = new SqlCommand("select PRODUCT_IMAGE from INFO_PRODUCT where PRODUCT_ID=@iddd", sc);
            get_purl.Parameters.AddWithValue("@iddd", pid);
            img1.ImageUrl = get_purl.ExecuteScalar().ToString();
            sc.Close();
        }
        else if (pid[0] == 'C')
        {
            SqlCommand get_pname = new SqlCommand("select CT_NAME from INFO_CT where CT_ID=@id", sc);
            get_pname.Parameters.AddWithValue("@id", pid);
            label1.Text = get_pname.ExecuteScalar().ToString();
            SqlCommand get_pintro = new SqlCommand("select CT_CONTENT from INFO_CT where CT_ID=@idd", sc);
            get_pintro.Parameters.AddWithValue("@idd", pid);
            string tex = get_pintro.ExecuteScalar().ToString();

            tex=tex.Replace(" ", "&nbsp");
            tex = tex.Replace("\n", "<br />");
            textbox1.Text = tex;
            SqlCommand get_purl = new SqlCommand("select CT_IMAGE from INFO_CT where CT_ID=@iddd", sc);
            get_purl.Parameters.AddWithValue("@iddd", pid);
            img1.ImageUrl = get_purl.ExecuteScalar().ToString();
            sc.Close();
        }


    }
}